<?php

if (validation_errors()) :
?>
<section class="content-header">
<div class='alert alert-block alert-error fade in'>
    <a class='close' data-dismiss='alert'>&times;</a>
    <h4 class='alert-heading'>
        <?php echo lang('channel_errors_message'); ?>
    </h4>
    <?php echo validation_errors(); ?>
</div>
</section>
<?php
endif;

$id = isset($channel->id) ? $channel->id : '';

?>

<!-- <section class="content-header">
      <h1>
        General Form Elements
        <small>Preview</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Forms</a></li>
        <li class="active">General Elements</li>
      </ol>
    </section> -->

<!-- Main content -->
<section class="content">
  <div class="row">
    <div class="col-xs-12">
        <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">编辑<?php echo building_photo_subtype()[$photoSubType]; ?></h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <?php echo form_open($this->uri->uri_string(), 'class="form-horizontal"'); ?>
              <div class="box-body">
              <div class="form-group">
                <?php echo form_label('所属域名', 'domain', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-10">
                        <select class="form-control select2" style="width: 100%;" name="domain" id="domain">
                        <?php foreach ($domain = building_domain() as $key => $obj) : ?>
                          <option value="<?php echo $key; ?>" <?php echo set_select('status', $key, (isset($photo->domain) ? $photo->domain : '')==$obj); ?>><?php echo $obj; ?></option>
                        <?php endforeach; ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                  <?php echo form_label('', '', array('class'=>'col-sm-2 control-label')); ?>
                  <div class="col-md-10">
                        <div id="container">
                            <a class="btn btn-default btn-lg " id="edit_pickfiles" href="#" >
                                <i class="glyphicon glyphicon-plus"></i>
                                <span>选择文件</span>
                            </a>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                  <label for="code" class="col-sm-2 control-label">图片</label>                    
                  <div class="col-sm-10">
                    <img src="<?php echo $photo->absolute_url; ?>" width="100" id="photo_url_img" /><br />
                    <input type="hidden" name="url" value="<?php echo $photo->url; ?>" style="display:none;" id="photo_url_name" />
                    <input type="hidden" name="platform" value="<?php echo $photo->platform; ?>" style="display:none;" />
                  </div>
                </div>

                <div class="form-group">
                <label for="code" class="col-sm-2 control-label">描述</label>
                    <div class="col-sm-10">
                    <input type="text" name="title" maxlength="100" class="form-control" value="<?php echo $photo->title; ?>" placeholder="描述" />
                      </div>
                </div>
                <?php if($photoType == 1 && $photoSubType == 3) :?>
                <div class="form-group">
                <label for="code" class="col-sm-2 control-label">标签</label>
                    <div class="col-sm-10">
                      <select class="form-control edit_tag_name" style="width: 100%;" name="desc[]"  multiple="multiple">
                        <?php foreach ($normal_tags as $key=>$value) : ?>
                            <option value="<?php echo $value; ?>" selected><?php echo $value; ?></option>
                        <?php endforeach; ?>
                      </select>
                      </div>
                </div>
                <?php endif;?>
                <?php if($photoType == 1 && $photoSubType == 3) :?>
                <div class="form-group">
                    <label for="code" class="col-sm-2 control-label">分类</label>
                    <div class="col-sm-10">     
                    <select class="form-control col-sm-6" name='pic_zone[]'>
                    <?php foreach ($buildingPicZone as $key => $value) : ?>
                        <option <?php if($photo->category == $key){echo 'selected';} ?> value ="<?php e($key);?>" > <?php e($value);?></option>
                    <?php endforeach;?>
                    </select>
                      </div>
                </div>
                <?php endif;?>
                <?php if($photoSubType == 3 || $photoSubType == 5) :?>
                <div class="form-group">
                    <label for="code" class="col-sm-2 control-label">版本</label>
                    <div class="col-sm-10">    
                      <select class="form-control col-sm-6" name='version[]'>
                      <?php if($photoType == 1 && $photoSubType == 3) :?>
                      <?php foreach ( building_tspic_version() as $key => $value) : ?>
                          <option <?php if($photo->version == $value){echo 'selected';} ?> value ="<?php e($value);?>" ><?php e($value);?></option>
                      <?php endforeach;?>
                      <?php endif;?>
                      <?php if($photoType == 1 && $photoSubType == 5) :?>
                      <?php foreach ( building_headpic_version() as $key => $value) : ?>
                          <option <?php if($photo->version == $value){echo 'selected';} ?> value ="<?php e($value);?>" ><?php e($value);?></option>
                      <?php endforeach;?>
                      <?php endif;?>
                      </select>
                    </div>
                </div>    
                <?php endif;?>
     </div>
                

              
              <!-- /.box-body -->

              <div class="box-footer">
                <input type="hidden" name="type" value="<?php echo $photoType; ?>" style="display:none;" />
                <input type="hidden" name="sub_type" value="<?php echo $photoSubType; ?>" style="display:none;" />
                <input type="hidden" name="target_id" value="<?php echo $targetId; ?>" style="display:none;" />
                <button type="submit" name='save' class="btn btn-primary"><?php echo lang('bf_action_save'); ?></button>
                <?php echo anchor('/buildings/bphoto/index/'.$targetId.'/'.$photoType.'/'.$photoSubType.'/', lang('bf_action_cancel'), 'class="btn btn-default pull-right"'); ?>
              </div>
            <?php echo form_close(); ?>
          </div>

          </div>
      </div>

</section>
